﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AppMain
{
    public partial class ConfirmBox : Form
    {
        private byte _type;
        public ConfirmBox(byte type)
        {
            _type = type;
            InitializeComponent();
            if (type > 0)
            {
                double temp = SwMatrix._dataToBeWritten[type];
                temp /= 10.0;
                Existing.Text = temp.ToString("##0.0");
                New.Text = temp.ToString("##0.0");
                OldUnits.Text = "sec";
                NewUnits.Text = "sec";
            }
            else
            {
                Existing.Text = SwMatrix._dataToBeWritten[type].ToString();
                New.Text = SwMatrix._dataToBeWritten[type].ToString("X0");
                OldUnits.Text = "";
                NewUnits.Text = "";
            }
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            if(New.Text != null)
            {
                double temp = Convert.ToDouble(New.Text);
                if (_type > 0)
                {
                    temp *= 10.0;
                }
                SwMatrix._dataToBeWritten[_type] = (short)temp;
                SwMatrix._registersChanged = true;
            }
            this.Close();
        }

        private void btnDiscard_Click(object sender, EventArgs e)
        {
            this.Close();
        }

    }
}
